package Day05;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

//冒泡排序
public class Day05N {
    public static void main(String[] args) {
        Random rd=new Random();
        int[] arr=new int[10];
        for (int i=0;i<arr.length;i++){
            arr[i]= rd.nextInt(100);
        }
        System.out.println(Arrays.toString(arr));
        for (int i=0;i<arr.length-1;i++){
            System.out.println("第"+(i+1)+"轮");
        for (int j=0;j<arr.length-1-i;j++){
            if (arr[j]>arr[j+1]){
                int key=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=key;
            }
            System.out.println("第"+(j+1)+"次");
            System.out.println(Arrays.toString(arr));//以数组的形式输出 省去遍历的过程
        }
        }
        System.out.println(Arrays.toString(arr));

        //用户输入几月几日 你告诉我 现在是第多少天 然后告诉我是星期几
        Scanner scan=new Scanner(System.in);
        int[] a=new int[]{0,31,29,31,30,31,30,31,31,30,31,30,31};
        System.out.println("请输入月份");
        int month=scan.nextInt();
        for (;;){
            if (month<1 || month>12){
                System.out.println("请输入正确月份");
                month=scan.nextInt();
            }else{
                break;
            }
        }
            System.out.println("请输入日期");
            int days=scan.nextInt();
            for (;;){
                if (days<1 || days>a[month]){
                    System.out.println("请输入正确日期");
                    days=scan.nextInt();
                }else {
                    break;
                }
            }
            for (int i=0;i<month;i++){
                days+=a[i];
            }
        switch (days%7){
            case 1:
                System.out.println("星期一");
                break;
            case 2:
                System.out.println("星期二");
                break;
            case 3:
                System.out.println("星期三");
                break;
            case 4:
                System.out.println("星期四");
                break;
            case 5:
                System.out.println("星期五");
                break;
            case 6:
                System.out.println("星期六");
                break;
            case 0:
                System.out.println("星期日");
                break;
        }
    }
}
